package com.verbetia.musictrends.persistence.hsqldb;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MusicEntity {
	
	private String id;
	private String musicdata;
	//private String date;
	private Date date;
	private String title;
	private String artist;
	private String album;
	private String amazonid;
	
	private static String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
	
    public static final String TODAY = "TODAY";
	public static final String NOT_TODAY = "NOT_TODAY";    

	
	public String getAlbum() {
		return Utils.HTMLEntityEncode(album);
	}
	public void setAlbum(String album) {
		this.album = album;
	}
	public String getAmazonid() {
		return amazonid;
	}
	public void setAmazonid(String amazonid) {
		this.amazonid = amazonid;
	}
	public String getArtist() {
		return Utils.HTMLEntityEncode(artist);
	}
	public void setArtist(String artist) {		
		this.artist = artist;
	}
	public Date getDate() {
		return date;
	}
	
	public String getDateFormated(String format) {
	
		if (format==null || format.equals("")) format = MusicEntity.DATE_FORMAT;
		
		 SimpleDateFormat sdf =
		        new SimpleDateFormat(format);
		 
		return sdf.format(this.date); 
	}

	
	public void setDate(Date date) {
		this.date = date;
	}
	public void setDate(String date) {
				
		//2008-04-14 17:44:37.531000000
		SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");			
		try {
			this.date = sdf.parse(date);
		} catch (ParseException pe)
		{
			System.out.println(pe);
		}
				
	}

	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getMusicdata() {
		return musicdata;
	}
	public void setMusicdata(String musicdata) {
		this.musicdata = musicdata;
	}
	public String getTitle() {
		return Utils.HTMLEntityEncode(title);
	}
	public void setTitle(String title) {		
		this.title = title;
	}
	
	
	public static MusicEntity create(String id, String date, String musicdata, String title, String artist, String album, String amazonid)
	{
		MusicEntity m = new MusicEntity();
		
		m.setId(id);
		m.setDate(date);
		m.setMusicdata(musicdata);
		m.setTitle(title);
		m.setAlbum(album);
		m.setArtist(artist);
		m.setAmazonid(amazonid);
		
		return m;
		
	}

}
